package com.learn.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/02/06
 * @description
 */
@Controller
public class ExceptionController {
    @RequestMapping("/")
    public String index() {
        String s = null;
        s.toString();
        return "index";
    }
    @ExceptionHandler(NullPointerException.class)
    @ResponseBody
    public String error(NullPointerException e) {
        return "空指针异常：" + e.getMessage();
    }
}
